package com.thebitstream.sandy.support;

import java.util.Collection;
import java.util.Set;

import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.Red5;

/**
 * @author Andy Shaules
 *
 */
public class EventService {

	public void sendEvent(final Object[] event) {

		IScope scope = Red5.getConnectionLocal().getScope();
		Collection<Set<IConnection>> clients = scope.getConnections();
		
		String sender=((ClientData) Red5.getConnectionLocal().getClient().getAttribute(Engine.DATA)).getId();
		for (Set<IConnection> connectionSet : clients) {

			for (final IConnection connection : connectionSet) {

				if (Red5.getConnectionLocal() != connection) {

					EventServiceNotifier caller = new EventServiceNotifier(sender, connection, event);
					caller.start();
				}
			}
		}
	}

}
